// 版权归陈超所有

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "CC_PlayerController.generated.h"

class USplineComponent;
class UCC_AbilitySystemComponent;
struct FGameplayTag;
class UDataAsset_InputConfig;
class ICC_EnemyInterface;
class UInputMappingContext;
class UInputAction;


/**
 * 
 */
UCLASS()
class CC_AURA_API ACC_PlayerController : public APlayerController
{
	GENERATED_BODY()

public:
	ACC_PlayerController();
	virtual void PlayerTick(float DeltaTime) override;
protected:
	virtual void BeginPlay() override;

	UPROPERTY()
	TObjectPtr<UCC_AbilitySystemComponent> CC_AbilitySystemComponent;		//能力系统组件

	UCC_AbilitySystemComponent* GetCC_AbilitySystemComponent();
	
/*鼠标追踪
 * 1.高亮敌人类
 */
#pragma region CurserTrace
private:
	//鼠标追踪变量
	TScriptInterface<ICC_EnemyInterface> LastActor;	//上一帧拾取的接口指针
	TScriptInterface<ICC_EnemyInterface> ThisActor;	//当前帧拾取的接口指针
	FHitResult CursorHit;		//鼠标点击位置
	
	void CurserTrace();	//鼠标追踪函数
#pragma endregion

/*输入设置
 * 1.移动输入
 * 2.能力输入
 */
#pragma region Inputs
protected:
	virtual void SetupInputComponent() override;
private:
	UPROPERTY(EditAnywhere, Category="CC|Input")
	TObjectPtr<UDataAsset_InputConfig> DataAssetInputConfig;
	
	void Move(const struct FInputActionValue& InputActionValue);
	void AbilityInputTagPressed(FGameplayTag InputTag);		//按下
	void AbilityInputTagReleased(FGameplayTag InputTag);	//结束
	void AbilityInputTagHold(FGameplayTag InputTag);		//持续
#pragma endregion

/*鼠标点击移动*/
#pragma region ClickToMove

private:
	FVector CachedDestination = FVector::ZeroVector;	//追击的目的地
	float FollowTime = 0.f;		//鼠标按住的时间
	float ShortPressThreshold = 0.5f;		//短按阈值
	bool bAutoRunning =false;		//是否自动追踪
	bool bTargetting = false;		//目标锁定
	
	UPROPERTY(EditDefaultsOnly, Category="CC|ClickToMove")
	float AutoRunAcceptanceRadius = 50.f;		//自动追踪到达目的地的半径后停止

	UPROPERTY(VisibleAnywhere, Category="CC|ClickToMove")
	TObjectPtr<USplineComponent> Spline;		//样条曲线

	void AutoRun();		//自动寻路
#pragma endregion
	
};
